package com.nuc.map;

import java.util.*;

/**
 * Time    : 2023/3/30 15:45
 * Author  : 王摇摆
 * FileName: DemoTest.java
 * Software: IntelliJ IDEA 2020.2.2
 * Blog    ：https://blog.csdn.net/weixin_44943389?type=blog
 */

public class DemoTest {
    public static void main(String[] args) {
        DemoTest.test_set();
        DemoTest.test_map();
        DemoTest.test_list();
    }

    private static void test_set() {
        Set<Integer> hashSet = new HashSet<>();

        for (int i = 10; i > 0; --i) {
            hashSet.add(i);
        }

        System.out.print("Set集合中的元素是：");
        for (Integer integer : hashSet) {
            System.out.print(integer + " ");
        }
        System.out.println();
        System.out.println("-------------");
    }

    private static void test_map() {
        Map<Integer, Integer> hashMap = new HashMap<>();

        for (int i = 10; i > 0; --i) {
            hashMap.put(i, i);
        }

        System.out.print("Map集合中的元素是：");
        Set<Map.Entry<Integer, Integer>> entrySet = hashMap.entrySet();
        for (Map.Entry<Integer, Integer> me : entrySet) {
            Integer value = me.getValue();
            System.out.print(value + " ");
        }
        System.out.println();

        System.out.println("map中1的值是"+hashMap.get(1));
        hashMap.put(1,100);
        System.out.println("map中1的值是"+hashMap.get(1));
        System.out.println("-------------");
    }

    private static void test_list() {
        List<Integer> arrayList = new ArrayList<>();

        for (int i = 10; i > 0; --i) {
            arrayList.add(i);
        }

        System.out.print("List集合中的元素是：");
        for (Integer integer : arrayList) {
            System.out.print(integer + " ");
        }
        System.out.println();
        System.out.println("-------------");
    }
}
